package com.base.blocking.queue;

import java.util.concurrent.BlockingQueue;

public class Producer implements Runnable {
    private final BlockingQueue queue;

    public Producer(BlockingQueue queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        try {
            while (true){
                queue.put(produce());
                Thread.sleep(200);
            }

        } catch (InterruptedException ex) {

        }
    }
    Object produce() {
        Object o = new Object();
        System.out.println("生产："+o);
        return o;}
}
